<?php

namespace Piwik\Plugins\AdsPlace;

use Piwik\Menu\MenuTop;
use Piwik\Piwik;
use Piwik\Menu\MenuPlace;

class Menu extends \Piwik\Plugin\Menu {

    public function configureTopMenu(MenuTop $menu) {

        $urlParams = $this->urlForActionWithDefaultUserParams('index', array('segment' => false, 'idSite' => false));
        $tooltip = Piwik::translate('AdsPlace_TopLinkSummary');

        $menu->addItem('AdsPlace_TopLinkName', null, $urlParams, 7, $tooltip);
    }

    public function configurePlaceMenu(MenuPlace $menu) {
        if (!Piwik::isUserIsAnonymous()) {

            if (Piwik::getCurrentUserLogin() == 'xfplay') {
                $menu->addItem('影音先锋广告', '投放方案设置', $this->urlForAction('xfjson'), 2, '投放方案设置');
                $menu->addItem('影音先锋广告', 'Redis等检测工具', $this->urlForAction('detection'), 3, 'Redis等检测工具');
            }

            $menu->addItem('报告', '整体报告', $this->urlForAction('report'), 30, '整体报告');
            $menu->addItem('报告', '投放报告', $this->urlForAction('adverteReport'), 32, '投放报告');
            $menu->addItem('报告', '物料报告', $this->urlForAction('mediasReport'), 33, '物料报告');

            $menu->addSystemItem('AdsPlace_PlaceManager', $this->urlForAction('index'), $order = 12);

            $menu->addSystemItem('媒体站点', $this->urlForAction('siteapp'), $order = 12);

            $menu->addToufangItem('投放广告', $this->urlForAction('setplace'), $order = 4);

            $menu->addToufangItem('物料管理', $this->urlForAction('medias'), $order = 4);
        }
    }

}
